import { isValidName } from '@/utils/rules';
import { reg_mail, wechat_reg, isNumberReg, reg_gb2312_en } from '@/utils/regs';

export const reasonColumns = [
  {
    title: '面试职位',
    dataIndex: 'hrPositionName',
    key: 'hrPositionName',
    customCell: (_column: any) => {
      return {
        style: {
          'min-width': '120px',
        },
      };
    },
  },
  {
    title: '企业名称',
    dataIndex: 'companyName',
    key: 'companyName',
    slots: { customRender: 'companyName' },
    customCell: (_column: any) => {
      return {
        style: {
          'min-width': '100px',
        },
      };
    },
  },
  {
    title: '推荐人',
    dataIndex: 'waiterName',
    key: 'waiterName',
    customCell: (_column: any) => {
      return {
        style: {
          'min-width': '80px',
        },
      };
    },
  },
  {
    title: '推荐理由',
    dataIndex: 'recommendReason',
    key: 'recommendReason',
  },
  {
    title: '推荐时间',
    dataIndex: 'createAt',
    key: 'createAt',
    customCell: (_column: any) => {
      return {
        style: {
          'min-width': '100px',
        },
      };
    },
  },
];
export const coachColumns = [
  {
    title: '沟通事由',
    dataIndex: 'origin',
    key: 'origin',
  },
  {
    title: '沟通方式',
    dataIndex: 'contactWay',
    key: 'contactWay',
    customRender: ({ text }: any) => {
      return text === 1 ? '电话' : '其他';
    },
  },
  // {
  //   title: '电话号码',
  //   dataIndex: 'mobile',
  //   key: 'mobile',
  //   customRender: ({ text, record }: any) => {
  //     return record.contactWay === 1 ? text : '-';
  //   },
  // },
  {
    title: '预约沟通时间',
    dataIndex: 'contactTime',
    key: 'contactTime',
  },

  {
    title: '申请预约时间',
    dataIndex: 'createAt',
    key: 'createAt',
  },
];

export const ordersColumns = [
  {
    title: '职位',
    dataIndex: 'positionName',
    key: 'positionName',
    slots: { customRender: 'positionName' },
    customCell: (_column: any) => {
      return {
        style: {
          'min-width': '100px',
        },
      };
    },
  },
  {
    title: '推荐人',
    dataIndex: 'waiterName',
    key: 'waiterName',
    customCell: (_column: any) => {
      return {
        style: {
          'min-width': '100px',
        },
      };
    },
  },
  {
    title: '推荐理由',
    dataIndex: 'reason',
    key: 'reason',
  },
  {
    title: '状态',
    dataIndex: 'state',
    key: 'state',
    customCell: (_column: any) => {
      return {
        style: {
          'min-width': '100px',
        },
      };
    },
  },
  {
    title: '匹配度',
    dataIndex: 'score',
    key: 'score',
    customRender: ({ text, record }: any) => {
      return text * 100 + '%';
    },
    customCell: (_column: any) => {
      return {
        style: {
          'min-width': '100px',
        },
      };
    },
  },
  {
    title: '预约时间',
    dataIndex: 'createAt',
    key: 'createAt',
    customCell: (_column: any) => {
      return {
        style: {
          'min-width': '120px',
        },
      };
    },
  },
];

export const jibenxinxiRules = {
  name: {
    required: true,
    trigger: 'change',
    validator: (_rule: any, value: any) => {
      if (value && isValidName(value)) {
        return Promise.resolve();
      } else {
        return Promise.reject(`真实姓名为必填项哦`);
      }
    },
  },
  genderEnum: {
    required: true,
    trigger: 'change',
    message: '请选择性别',
  },
  dateOfBirth: {
    required: true,
    trigger: 'change',
    message: '出生年月为必填项哦',
    type: 'object',
  },
  workStartYear: {
    required: true,
    trigger: 'change',
    message: '工作年限为必填项哦',
    type: 'object',
  },
  wechat: {
    required: false,
    trigger: 'change',
    validator: (rule: any, value: any) => {
      if (!value) {
        return Promise.resolve();
      } else {
        if (!wechat_reg.test(value)) {
          return Promise.reject(`请填写6-20位字母、数字、下划线或减号组合`);
        } else {
          return Promise.resolve();
        }
      }
    },
  },
  email: {
    required: false,
    trigger: 'change',
    validator: (rule: any, value: any) => {
      if (!value) {
        return Promise.resolve();
      }
      if (!reg_mail.test(value)) {
        return Promise.reject('请填写正确的邮箱');
      }
      return Promise.resolve();
    },
  },
  currentAreacode: {
    required: true,
    trigger: 'change',
    message: '请选择当前所在区域',
  },
  currentStreetCode: {
    required: true,
    trigger: 'change',
    message: '请选择当前所在街道',
  },
  currentSalary: {
    required: true,
    trigger: 'change',
    validator: (rule: any, value: any) => {
      const error = value?.every((t: any) => isNumberReg.test(t));
      if (!value?.length || !error) {
        return Promise.reject(`薪资为必填项哦`);
      } else {
        return Promise.resolve();
      }
    },
  },
};

export const gongzuojingliRules = {
  companyName: {
    required: true,
    trigger: 'change',
    validator: (rule: any, value: any) => {
      if (!value) {
        return Promise.reject('请填写公司名称');
      } else {
        if (!reg_gb2312_en().test(value)) {
          return Promise.reject('请填写公司名称');
        } else {
          return Promise.resolve();
        }
      }
    },
  },
  industryCode: {
    required: true,
    trigger: 'change',
    message: '请选择所在行业',
  },
  positionCode: {
    required: true,
    trigger: 'change',
    message: '请选择职位名称',
  },
  onJobTime: {
    required: true,
    message: '请选择在职时间',
    type: 'array',
    len: 2,
  },
};

export const tuijianbaogaoColumns = [
  {
    title: '推荐职位',
    dataIndex: 'tuijianzhiwei',
    key: 'tuijianzhiwei',
    slots: { customRender: 'tuijianzhiwei' },
  },
  {
    title: '匹配度',
    dataIndex: 'matchingScore',
    key: 'matchingScore',
    slots: { customRender: 'matchingScore' },
  },
  {
    title: '报告更新时间',
    dataIndex: 'updateAt',
    key: 'updateAt',
  },
  {
    title: '操作',
    dataIndex: 'actions',
    key: 'actions',
    slots: { customRender: 'actions' },
  },
];

export const genJinJiluTypes = [
  {
    label: '首次沟通',
    value: 'first',
  },
  {
    label: '面试辅导',
    value: 'interview',
  },
  {
    label: '面试反馈',
    value: 'feedback',
  },
  {
    label: '入职跟进',
    value: 'onboard',
  },
  {
    label: '其他',
    value: 'other',
  },
];

export const genJinJiluTypes2 = [
  {
    label: '面试辅导',
    value: 'interview',
  },
  {
    label: '面试反馈',
    value: 'feedback',
  },
];
